package com.springboot.cloud.demos.ribbon.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.QuestionForm;
import com.springboot.cloud.demos.entity.form.UnitForm;
import com.springboot.cloud.demos.ribbon.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class QuestionController {

    @Autowired
    private QuestionService questionService;

    @GetMapping("/question")
    public Result query(@RequestParam("unitId") String unitId) {
        return questionService.query(unitId);
    }
    @GetMapping("/question/{id}")
    public Result get(@PathVariable(value = "id") String id) {
        return questionService.get(id);
    }
    @PostMapping("/question")
    public Result add(@RequestBody QuestionForm questionForm) {
        return questionService.save(questionForm);
    }

    @PutMapping(value = "/question")
    public Result update(@RequestBody QuestionForm questionForm) {
        return questionService.update(questionForm);
    }
}
